/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('adp-hub', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model CreateProductVersionRequest {
  productDescription?: string(name='productDescription'),
  productName?: string(name='productName'),
  version?: string(name='version'),
}

model CreateProductVersionResponseBody = {
  code?: string(name='code'),
  data?: {
    uid?: string(name='uid'),
  }(name='data'),
  msg?: string(name='msg'),
}

model CreateProductVersionResponse = {
  headers: map[string]string(name='headers'),
  body: CreateProductVersionResponseBody(name='body'),
}

async function createProductVersion(request: CreateProductVersionRequest): CreateProductVersionResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createProductVersionWithOptions(request, headers, runtime);
}

async function createProductVersionWithOptions(request: CreateProductVersionRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateProductVersionResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.productDescription)) {
    body.productDescription = request.productDescription;
  }
  if (!Util.isUnset(request.productName)) {
    body.productName = request.productName;
  }
  if (!Util.isUnset(request.version)) {
    body.version = request.version;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('CreateProductVersion', '2021-11-25', 'HTTPS', 'POST', 'AK', `/api/v2/hub/product-versions`, 'json', req, runtime);
}

model CreateVersionPackageInstallConfigRequest {
  environmentUID?: string(name='environmentUID'),
}

model CreateVersionPackageInstallConfigResponseBody = {
  code?: string(name='code'),
  data?: string(name='data'),
  msg?: string(name='msg'),
}

model CreateVersionPackageInstallConfigResponse = {
  headers: map[string]string(name='headers'),
  body: CreateVersionPackageInstallConfigResponseBody(name='body'),
}

async function createVersionPackageInstallConfig(request: CreateVersionPackageInstallConfigRequest): CreateVersionPackageInstallConfigResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createVersionPackageInstallConfigWithOptions(request, headers, runtime);
}

async function createVersionPackageInstallConfigWithOptions(request: CreateVersionPackageInstallConfigRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateVersionPackageInstallConfigResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.environmentUID)) {
    body.environmentUID = request.environmentUID;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('CreateVersionPackageInstallConfig', '2021-11-25', 'HTTPS', 'POST', 'AK', `/api/v2/hub/version-packages/install-configs`, 'json', req, runtime);
}

model CreateVersionPackageLicenseRequest {
  customProductQuotaList?: [ 
    {
      description?: string(name='description'),
      key?: string(name='key'),
      value?: string(name='value'),
    }
  ](name='customProductQuotaList'),
  environmentUID?: string(name='environmentUID'),
  expiredTime?: long(name='expiredTime'),
  machineFingerprint?: string(name='machineFingerprint'),
  productVersionUID?: string(name='productVersionUID'),
}

model CreateVersionPackageLicenseResponseBody = {
  code?: string(name='code'),
  data?: string(name='data'),
  msg?: string(name='msg'),
}

model CreateVersionPackageLicenseResponse = {
  headers: map[string]string(name='headers'),
  body: CreateVersionPackageLicenseResponseBody(name='body'),
}

async function createVersionPackageLicense(request: CreateVersionPackageLicenseRequest): CreateVersionPackageLicenseResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createVersionPackageLicenseWithOptions(request, headers, runtime);
}

async function createVersionPackageLicenseWithOptions(request: CreateVersionPackageLicenseRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateVersionPackageLicenseResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.customProductQuotaList)) {
    body.customProductQuotaList = request.customProductQuotaList;
  }
  if (!Util.isUnset(request.environmentUID)) {
    body.environmentUID = request.environmentUID;
  }
  if (!Util.isUnset(request.expiredTime)) {
    body.expiredTime = request.expiredTime;
  }
  if (!Util.isUnset(request.machineFingerprint)) {
    body.machineFingerprint = request.machineFingerprint;
  }
  if (!Util.isUnset(request.productVersionUID)) {
    body.productVersionUID = request.productVersionUID;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('CreateVersionPackageLicense', '2021-11-25', 'HTTPS', 'POST', 'AK', `/api/v2/hub/version-packages/product-licenses`, 'json', req, runtime);
}

model DeleteProductResponseBody = {
  code?: string(name='code'),
  msg?: string(name='msg'),
}

model DeleteProductResponse = {
  headers: map[string]string(name='headers'),
  body: DeleteProductResponseBody(name='body'),
}

async function deleteProduct(uid: string): DeleteProductResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteProductWithOptions(uid, headers, runtime);
}

async function deleteProductWithOptions(uid: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteProductResponse {
  uid = OpenApiUtil.getEncodeParam(uid);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  return doROARequest('DeleteProduct', '2021-11-25', 'HTTPS', 'DELETE', 'AK', `/api/v2/hub/products/${uid}`, 'json', req, runtime);
}

model DeleteProductVersionResponseBody = {
  code?: string(name='code'),
  msg?: string(name='msg'),
}

model DeleteProductVersionResponse = {
  headers: map[string]string(name='headers'),
  body: DeleteProductVersionResponseBody(name='body'),
}

async function deleteProductVersion(uid: string): DeleteProductVersionResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteProductVersionWithOptions(uid, headers, runtime);
}

async function deleteProductVersionWithOptions(uid: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteProductVersionResponse {
  uid = OpenApiUtil.getEncodeParam(uid);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  return doROARequest('DeleteProductVersion', '2021-11-25', 'HTTPS', 'DELETE', 'AK', `/api/v2/hub/product-versions/${uid}`, 'json', req, runtime);
}

model GetProductVersionResponseBody = {
  code?: string(name='code'),
  data?: {
    createdAt?: string(name='createdAt'),
    deletedAt?: string(name='deletedAt'),
    document?: string(name='document'),
    platforms?: string(name='platforms'),
    productUID?: string(name='productUID'),
    readme?: string(name='readme'),
    uid?: string(name='uid'),
    updatedAt?: string(name='updatedAt'),
    version?: string(name='version'),
  }(name='data'),
  msg?: string(name='msg'),
}

model GetProductVersionResponse = {
  headers: map[string]string(name='headers'),
  body: GetProductVersionResponseBody(name='body'),
}

async function getProductVersion(uid: string): GetProductVersionResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getProductVersionWithOptions(uid, headers, runtime);
}

async function getProductVersionWithOptions(uid: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetProductVersionResponse {
  uid = OpenApiUtil.getEncodeParam(uid);
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  return doROARequest('GetProductVersion', '2021-11-25', 'HTTPS', 'GET', 'AK', `/api/v2/hub/product-versions/${uid}`, 'json', req, runtime);
}

model ListProductVersionsRequest {
  pageNum?: int32(name='pageNum'),
  pageSize?: int32(name='pageSize'),
  uid?: string(name='uid'),
}

model ListProductVersionsResponseBody = {
  code?: string(name='code'),
  data?: {
    list?: [ 
      {
        createdAt?: string(name='createdAt'),
        deletedAt?: string(name='deletedAt'),
        productUID?: string(name='productUID'),
        uid?: string(name='uid'),
        updatedAt?: string(name='updatedAt'),
        version?: string(name='version'),
      }
    ](name='list'),
    pageNum?: int32(name='pageNum'),
    pageSize?: int32(name='pageSize'),
    total?: int32(name='total'),
  }(name='data'),
  msg?: string(name='msg'),
}

model ListProductVersionsResponse = {
  headers: map[string]string(name='headers'),
  body: ListProductVersionsResponseBody(name='body'),
}

async function listProductVersions(request: ListProductVersionsRequest): ListProductVersionsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listProductVersionsWithOptions(request, headers, runtime);
}

async function listProductVersionsWithOptions(request: ListProductVersionsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListProductVersionsResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.pageNum)) {
    query.pageNum = request.pageNum;
  }
  if (!Util.isUnset(request.pageSize)) {
    query.pageSize = request.pageSize;
  }
  if (!Util.isUnset(request.uid)) {
    query.uid = request.uid;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('ListProductVersions', '2021-11-25', 'HTTPS', 'GET', 'AK', `/api/v2/hub/product-versions`, 'json', req, runtime);
}

model ListProductsRequest {
  name?: string(name='name'),
  pageNum?: int32(name='pageNum'),
  pageSize?: int32(name='pageSize'),
}

model ListProductsResponseBody = {
  code?: string(name='code'),
  data?: {
    list?: [ 
      {
        createdAt?: string(name='createdAt'),
        deletedAt?: string(name='deletedAt'),
        description?: string(name='description'),
        isPublic?: string(name='isPublic'),
        name?: string(name='name'),
        title?: string(name='title'),
        uid?: string(name='uid'),
        updatedAt?: string(name='updatedAt'),
      }
    ](name='list'),
    pageNum?: int32(name='pageNum'),
    pageSize?: int32(name='pageSize'),
    total?: int32(name='total'),
  }(name='data'),
  msg?: string(name='msg'),
}

model ListProductsResponse = {
  headers: map[string]string(name='headers'),
  body: ListProductsResponseBody(name='body'),
}

async function listProducts(request: ListProductsRequest): ListProductsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listProductsWithOptions(request, headers, runtime);
}

async function listProductsWithOptions(request: ListProductsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListProductsResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.name)) {
    query.name = request.name;
  }
  if (!Util.isUnset(request.pageNum)) {
    query.pageNum = request.pageNum;
  }
  if (!Util.isUnset(request.pageSize)) {
    query.pageSize = request.pageSize;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('ListProducts', '2021-11-25', 'HTTPS', 'GET', 'AK', `/api/v2/hub/products`, 'json', req, runtime);
}

model ListVersionPackagesRequest {
  uid?: string(name='uid'),
}

model ListVersionPackagesResponseBody = {
  code?: string(name='code'),
  data?: [ 
    {
      packageStatus?: string(name='packageStatus'),
      packageType?: string(name='packageType'),
      packageUID?: string(name='packageUID'),
      platform?: string(name='platform'),
      productVersionUID?: string(name='productVersionUID'),
      url?: string(name='url'),
    }
  ](name='data'),
  msg?: string(name='msg'),
}

model ListVersionPackagesResponse = {
  headers: map[string]string(name='headers'),
  body: ListVersionPackagesResponseBody(name='body'),
}

async function listVersionPackages(request: ListVersionPackagesRequest): ListVersionPackagesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listVersionPackagesWithOptions(request, headers, runtime);
}

async function listVersionPackagesWithOptions(request: ListVersionPackagesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListVersionPackagesResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.uid)) {
    query.uid = request.uid;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('ListVersionPackages', '2021-11-25', 'HTTPS', 'GET', 'AK', `/api/v2/hub/version-packages`, 'json', req, runtime);
}

model UpdateProductRequest {
  description?: string(name='description'),
  isPublic?: string(name='isPublic'),
  title?: string(name='title'),
}

model UpdateProductResponseBody = {
  code?: string(name='code'),
  msg?: string(name='msg'),
}

model UpdateProductResponse = {
  headers: map[string]string(name='headers'),
  body: UpdateProductResponseBody(name='body'),
}

async function updateProduct(uid: string, request: UpdateProductRequest): UpdateProductResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateProductWithOptions(uid, request, headers, runtime);
}

async function updateProductWithOptions(uid: string, request: UpdateProductRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateProductResponse {
  Util.validateModel(request);
  uid = OpenApiUtil.getEncodeParam(uid);
  var body : map[string]any= {};
  if (!Util.isUnset(request.description)) {
    body.description = request.description;
  }
  if (!Util.isUnset(request.isPublic)) {
    body.isPublic = request.isPublic;
  }
  if (!Util.isUnset(request.title)) {
    body.title = request.title;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('UpdateProduct', '2021-11-25', 'HTTPS', 'PUT', 'AK', `/api/v2/hub/products/${uid}`, 'json', req, runtime);
}

model UpdateProductVersionRequest {
  document?: string(name='document'),
  readme?: string(name='readme'),
}

model UpdateProductVersionResponseBody = {
  code?: string(name='code'),
  msg?: string(name='msg'),
}

model UpdateProductVersionResponse = {
  headers: map[string]string(name='headers'),
  body: UpdateProductVersionResponseBody(name='body'),
}

async function updateProductVersion(uid: string, request: UpdateProductVersionRequest): UpdateProductVersionResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateProductVersionWithOptions(uid, request, headers, runtime);
}

async function updateProductVersionWithOptions(uid: string, request: UpdateProductVersionRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateProductVersionResponse {
  Util.validateModel(request);
  uid = OpenApiUtil.getEncodeParam(uid);
  var body : map[string]any= {};
  if (!Util.isUnset(request.document)) {
    body.document = request.document;
  }
  if (!Util.isUnset(request.readme)) {
    body.readme = request.readme;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('UpdateProductVersion', '2021-11-25', 'HTTPS', 'PUT', 'AK', `/api/v2/hub/product-versions/${uid}`, 'json', req, runtime);
}

